
pipeline {
    agent {
        //指定此Pipeline将在动态Jenkins Slave中执行
        label 'python-script'
    }
    options {
        //设置管道运行的超时时间，在此之后，Jenkins将中止管道
        timeout(time: 20, unit: 'MINUTES')
        // 失败重试次数
        retry(2)
        //输出时间戳
        timestamps()
    }
    environment {
        //JOB所在根目录
        WORKSPACE_PATH = "/home/python_node/python_script/${JOB_NAME}"	
		cli_path="/opt/python_script/workspace/HttpRunner/httprunner"
		interface_script="/opt/python_script/workspace/Interface_script_dataquality/数据质量/testsuites"
		report_path="/opt/python_script/test_resport/resports"
		env_path="/opt/python_script/workspace/conf"
    }
	stages {
		stage('获取采集工具接口测试脚本'){
			steps{
				echo "获取采集工具接口测试脚本"
				cleanWs()
			    git credentialsId: 'b0bf5539-d8a8-4edf-92c1-1709115c2cff', url: 'http://192.168.101.94:8081/Data-Middleground-Develop-Area/product-test/InterfaceTest-script/ETLTools-ETLDaq-interfaceTest.git'
			}
		}
// 		stage('执行测试用例'){
// 			steps{
// 				echo "执行接口测试脚本"
// 			    sh  ''' 
// 			 		  python ${cli_path}/cli.py  ${interface_script}/数据质量.yaml   --dot-env-path ${env_path}/test.env     --report-file  ${report_path}/dataQuality-$(date +%Y%m%d.%H:%M:%S).html 
// 				   '''
// 				sh '''
//     				  result=` find /home/python_node/python_script/test_resport/resports  -mtime +10 -name "*.html"`
//     				  if [ -z "$result" ]
//                       then
//                           echo '不存在大于10天的html文件'
//                       else
//     				      rm -rf $result
//     				  fi
// 				  '''	
// 		        }   
// 		    }
    }
	
    post {
        success {
             echo "'${env.JOB_NAME} [${env.BUILD_NUMBER}]' 拉取成功"
        }
        failure {
            echo "'${env.JOB_NAME} [${env.BUILD_NUMBER}]' 拉取失败"
        }
    }
}
